@using Bootstrap_Project.Web.Controllers

@{
    ViewBag.Title = "EFM";
}

@helper LoggedInUser()
{   
    if (User != null && User.Identity != null && User.Identity.IsAuthenticated)
    { 
    @:Hello, @User.Identity.Name
    }
}
<div class="container-fluid" ng-controller="MyCtrl">
    <div class="row" >
        <div class="text-right">
            <h3>@LoggedInUser()</h3>
        </div>

        <div class="page-header">
            <h2>EFM</h2>
        </div>

        <form name="searchForm" class="form-horizontal well" role="form" ng-controller="dateValidator">
            <fieldset>
                <legend>Search</legend>

                <div class="row">
                    <div class="col-sm-12 col-md-12 col-lg-6">

                        <div class="form-group">
                            <div class="col-sm-2">
                                <p class="control-label">Search</p>
                            </div>
                            <div class="col-sm-6">
                                <input type="text" ng-init="condition=''"  ng-model="condition" class="form-control tt" data-toggle="tooltip" title="<div class='text-left'>Fixtures can be searched by the following attributes:<br><ul><li>Fixture name</li><li>Vessel name</li><li>Owner</li><li>Character</li><li>Fixture number</li><li>Operator (full or parts of fullname)</li><li>Broker (full or parts of fullname)</li></ul></div>" />
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-2">
                                <p class="control-label">Date</p>
                            </div>
                            <div class="col-sm-3">
                                <span class="k-widget k-datepicker k-header k-input">
                                    <span class="k-picker-wrap k-state-default">
                                        <input kendo-date-picker type="text" class="k-input" ng-init="dateFrom=''" name="dateFrom" ng-model="dateFrom" placeholder="<dd.MM.yyyy>" ng-pattern="datePattern" 
                                            ng-blur="dateFrom=check(dateFrom, !searchForm.dateFrom.$error.pattern)" k-parse-formats="formatsDate" k-format="formatDate" />
                                        <span class="k-select" role="button" unselectable="on"><span class="k-icon k-i-calendar" unselectable="on">select</span></span>
                                    </span>
                                </span>
                            </div>
                            <div class="col-sm-3">
                                <span class="k-widget k-datepicker k-header k-input">
                                    <span class="k-picker-wrap k-state-default">
                                        <input kendo-date-picker type="text" class="k-input" ng-init="dateTo=''" name="dateTo" ng-model="dateTo" placeholder="<dd.MM.yyyy>" 
                                            ng-blur="dateTo=check(dateTo, !searchForm.dateTo.$error.pattern)" ng-pattern="datePattern" k-parse-formats="formatsDate" k-format="formatDate" />
                                        <span class="k-select" role="button" unselectable="on"><span class="k-icon k-i-calendar" unselectable="on">select</span></span>
                                    </span>
                                </span>
                            </div>
                        </div>

                        <div class="col-sm-4 col-sm-offset-2">
                            <div class="form-group" style="margin-bottom: 5px">
                                <div class="col-sm-12">
                                    <div class="checkbox">
                                        <label>
                                            <input type="checkbox" ng-init="isCurrentUserPrimary=false" ng-model=" isCurrentUserPrimary" > 
                                            Current user as operator (primary)
                                        </label>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group" style="margin-bottom: 5px">
                                <div class="col-sm-12">
                                    <div class="checkbox">
                                        <label>
                                            <input type="checkbox" ng-init="isCurrentUserSecondary=false" ng-model="isCurrentUserSecondary" >
                                            Current user as operator (secondary)
                                        </label>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-sm-12">
                                    <div class="checkbox">
                                        <label>
                                            <input type="checkbox" ng-init="isActive=false" ng-model="isActive" >
                                            Only active fixtures
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="col-sm-4">
                            <div class="col-sm-12">Demurrage status</div>
                            <div class="form-group" style="margin-bottom: 5px">
                                <div class="col-sm-12">
                                    <div class="checkbox">
                                        <label>
                                            <input type="radio" ng-init="demurrageStatus='All'" ng-model="demurrageStatus" name="optionsRadios"  id="optionsRadios1" value="All" checked="">
                                            All
                                        </label>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group" style="margin-bottom: 5px">
                                <div class="col-sm-12">
                                    <div class="checkbox">
                                        <label>
                                            <input type="radio" ng-model="demurrageStatus" name="optionsRadios2" id="optionsRadios2"  value="Settled">
                                            Settled
                                        </label>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-sm-12">
                                    <div class="checkbox">
                                        <label>
                                            <input type="radio" ng-model="demurrageStatus" name="optionsRadios3" id="optionsRadios3"  value="Unsettled">
                                            Unsettled
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div id="errorDiv" class="hiddiv">
                        <div class="col-sm-12 col-md-12 col-lg-6">
                            <div class="panel panel-danger">
                                <div class="panel-heading">
                                    <h3 class="panel-title">Service returned an error</h3>
                                </div>
                                <div class="panel-body">
                                    <h4>If you see this than something really bad happened and services returned an error.
                                        Please report the bug and attach following messages to your report.
                                    </h4>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>

                <div class="col-sm-12">
                    <input type="submit" ng-click="searchFixture(condition, dateTo, dateFrom, demurrageStatus, isActive,
                                    isCurrentUserPrimary, isCurrentUserSecondary)" 
                        value="Search" class="btn btn-default" />
                </div>
    </fieldset>
        </form>
        @Html.Partial("_shippingGrid")
</div>
</div>
<div id="loading"></div>

@section scripts
{
    @*@Scripts.Render("~/Scripts/angular.min.js")
@Scripts.Render("~/Scripts/angular-mocks.js")
    @Scripts.Render("~/Scripts/angular-kendo.min.js")
    @Scripts.Render("~/OwnScripts/gridModule.js")
    @Scripts.Render("~/OwnScripts/portModule.js")
    @Scripts.Render("~/OwnScripts/basicFunctions.js")
    @Scripts.Render("~/OwnScripts/dateValidation.js")
    @Scripts.Render("~/OwnScripts/calculationModule.js")
    @Scripts.Render("~/OwnScripts/popupModule.js")
    @Scripts.Render("~/OwnScripts/commonCalculate.js")
    @Scripts.Render("~/OwnScripts/serviceModule.js")
    @Scripts.Render("~/OwnScripts/gridDefined.js")*@
    <script>
        require(["Scripts/app/common"], function () {
            require(["Scripts/app/Contest/Index"]);
        });
    </script>
}
